﻿@model Dexter.Web.Mvc.ViewModel.Backoffice.ViewsData.PostController.PostListViewData
@{
	ViewBag.Title = "Index";
	Layout = "~/Areas/Admin/Views/Shared/_BackOffice.cshtml";
}
<section class="grid_12">
	<div class="block-border">
		<form class="block-content form" id="table_form" method="post" action="">
			<h1>Recent Posts</h1>
				
			<div class="block-controls">
				@Html.RenderBackOffice(Model.Posts.PageSize, Model.Posts.PageIndex, Model.Posts.TotalCount, HttpContext.Current.Request.Url.ToString ().ToLowerInvariant ().Contains ( "page" )  ? HttpContext.Current.Request.Url.ToString () :  HttpContext.Current.Request.Url + "/Index")
			</div>


			<div class="no-margin">
				<table class="table" cellspacing="0" width="100%">
				
					<thead>
						<tr>
							<th class="col">ID</th>
							<th scope="col">Title</th>
							<th scope="col">Categories</th>
							<th scope="col">Publish Date</th>
							<th scope="col">Tags</th>
							<th scope="col">Comments</th>
							<th scope="col">Trackbacks</th>
							<th scope="col" class="table-actions">Actions</th>
						</tr>
					</thead>
					@foreach (var post in Model.Posts.Result) {
						<tr>
							<th scope="row" class="table-check-cell">
								@post.Id
							</th>
							<td>
								<a href="@U.Post.Detail(post)">
									@post.Title
								</a>
							</td>
							<td>
								<ul class="keywords">
									@{int c = 0;}
										@foreach(var category in post.Categories) {
											if (c >3) { c = 0; }
											if (c ==0) {
												<li>@category.Name</li>
											}

											if (c ==1) {
												<li class="orange-keyword">@category.Name</li>
											}

											if (c ==2) {
												<li class="purple-keyword">@category.Name</li>
											}

											if (c ==3) {
												<li class="green-keyword">@category.Name</li>
											}
										
											c++;
										}
								</ul>
							</td>
							<td>@post.PublishDate</td>
							<td>
								<ul class="keywords">
									@{ 
										int p = 0;
									}
									@foreach(var tag in post.Tags) {
										if (p >3) { p = 0; }

										if (p == 0) {
											<li>@tag</li>
										}

										if (p == 1) {
											<li class="orange-keyword">@tag</li>
										}

										if (p == 2) {
											<li class="purple-keyword">@tag</li>
										}

										if (p == 3) {
											<li class="green-keyword">@tag</li>
										}
										
										p++;
									}
								</ul>
							</td>
							<td>@post.TotalComments</td>
							<td>@post.TotalTrackback</td>
							<td class="table-actions">
								<a href="@U.Post.Detail(post)" title="View" class="with-tip" target="_blank"><img src="@Url.Content( "~/admin/Resources/images/Icons/Fugue/magnifier.png" )" width="16" height="16" alt="View Item" /></a>
								<a href="@U.Post.Edit(post)" title="Edit" class="with-tip"><img src="@Url.Content( "~/admin/Resources/images/Icons/Fugue/pencil.png" )" width="16" height="16" alt="Edit Item" /></a>
								<a href="@U.Post.Delete(post)" title="Delete" class="with-tip"><img src="@Url.Content( "~/admin/Resources/images/Icons/Fugue/cross-circle.png" )" width="16" height="16" alt="Delete Item" /></a>
							</td>
						</tr>

					}
				</table>

			</div>

			<ul class="message no-margin">
				<li>Results @Model.Posts.PageIndex - @Model.Posts.PageSize out of @Model.Posts.TotalCount</li>
			</ul>
		</form>
	</div>
</section>